package com.system.manager.modules.risk.service.impl;

import com.system.manager.common.annotation.CurrSubject;
import com.system.manager.modules.authorized.entity.Subject;
import com.system.manager.modules.authorized.entity.User;
import com.system.manager.modules.authorized.service.IUserService;
import com.system.manager.modules.risk.entity.StaffStation;
import com.system.manager.modules.risk.entity.TbAssessment;

import com.system.manager.modules.risk.mapper.TbAssessmentMapper;
import com.system.manager.modules.risk.service.IStaffStationService;
import com.system.manager.modules.risk.service.ITbAssessmentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.system.manager.modules.risk.service.ITbTaskService;
import com.system.manager.modules.risk.vo.UserDate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yxp
 * @since 2021-11-11
 */
@Service
public class TbAssessmentServiceImpl extends ServiceImpl<TbAssessmentMapper, TbAssessment> implements ITbAssessmentService {

    @Autowired
    private ITbTaskService iTbTaskService;
    @Autowired
    private ITbAssessmentService iTbAssessmentService;
    //生成用户评估表
    @Override
    public UserDate<TbAssessment> makeAssessage(@CurrSubject Subject subject) {

        UserDate userDate = new UserDate();
        userDate.setCode(0);
        userDate.setCount(1);
        userDate.setMsg("评估表信息");
        String score = iTbTaskService.findScore(subject);
        String aviScore = iTbTaskService.findAviScore(subject);

        String fileScore = iTbTaskService.findFileScore(subject);
        List<String> list = new ArrayList<>();
        list.add(score);
        list.add(aviScore);

        list.add(fileScore);
        String score1 = iTbAssessmentService.allScore(subject);
        list.add(score1);
        userDate.setData(list);
        return userDate;
    }
    //计算总分
    @Override
    public String allScore(@CurrSubject Subject subject) {
        String score = iTbTaskService.findScore(subject);
        String aviScore = iTbTaskService.findAviScore(subject);

        String fileScore = iTbTaskService.findFileScore(subject);
        int result = 0;
        result += Integer.valueOf(score) * 0.5;
        result += Integer.valueOf(aviScore) * 0.2;

        result += Integer.valueOf(fileScore) * 0.1;
        return String.valueOf(result);
    }
}
